import type { R, TableDataInfo } from '@/api/model/resultModel';
import type { XyywGoodsForm, XyywGoodsQuery, XyywGoodsVo } from '@/api/xyyw/model/goodsModel';
import { request } from '@/utils/request';

// 查询商品列表
export function listGoods(query?: XyywGoodsQuery) {
  return request.get<TableDataInfo<XyywGoodsVo>>({
    url: '/xyyw/goods/list',
    params: query,
  });
}

// 查询商品详细
export function getGoods(goodId: number) {
  return request.get<R<XyywGoodsVo>>({
    url: `/xyyw/goods/${goodId}`,
  });
}

// 新增商品
export function addGoods(data: XyywGoodsForm) {
  return request.post<R<void>>({
    url: '/xyyw/goods',
    data,
  });
}

// 修改商品
export function updateGoods(data: XyywGoodsForm) {
  return request.put<R<void>>({
    url: '/xyyw/goods',
    data,
  });
}

// 删除商品
export function delGoods(goodIds: number | Array<number>) {
  return request.delete<R<void>>({
    url: `/xyyw/goods/${goodIds}`,
  });
}
